import React, { Component } from 'react'

import { connect } from "react-redux"
import action from '../../../store/action/index.js'

import "./store_detail.less"

import cookies from "js-cookie"
class StoreDetail extends Component {
    render() {
        return (
            <div className="store_detail_box">
                <div className="store_detail_hende_box">
                    <span className="iconfont icon-fanhui2" onClick={() => {
                        // 跳路由
                        sessionStorage.setItem("flag", JSON.stringify(false))
                        this.props.history.push('/list')
                    }} ></span>

                    <span className="store_detail_hende_span">店铺详情</span>
                    <span></span>
                </div>
                <div className="store_detail_top_box">
                    <div>
                        <h2>{this.props.storeMess[0].store_mess}</h2>
                    </div>
                    <div onClick={() => { this.changeStoreCollect() }}>
                        {
                            this.props.collection_store === "1" ? <p className="store_detail_top_p">已收藏</p> : <p className="store_detail_top_p2">+收藏</p>
                        }
                    </div>
                </div>

                <div className="store_detail_top_box">
                    <div>
                        <h2>联系电话</h2>
                    </div>
                    <div>
                        <p>{this.props.storeMess[0].store_phone}</p>
                    </div>
                </div>

                <div className="store_detail_top_box">
                    <div>
                        <h2>开店时间</h2>
                    </div>
                    <div>
                        <p>{this.props.storeMess[0].store_timer}</p>
                    </div>
                </div>
            </div>
        )
    }

    // 收藏调接口
    changeStoreCollect = () => {
        this.props.changeStoreCollect({
            store_id: this.props.storeMess[0].store_id,
            user_id: cookies.get('user_id')
        })
    }
}

export default connect(state => state.foodf, action.foodf)(StoreDetail)
